﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Smartdispatch
{
    public partial class ModelLive : Form
    {
        public ModelLive()
        {
            InitializeComponent();
            this.FormClosing += ModelLive_FormClosing;
            BackgroundImage = Image.FromFile("backgroup.gif");
            BackgroundImageLayout = ImageLayout.Stretch;
            this.VisibleChanged += ModelLive_VisibleChanged;
        }

        private void ModelLive_VisibleChanged(object sender, EventArgs e)
        {
            if (Visible)
            TagNameEntity.Step=0;
        }

        private void ModelLive_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            this.Visible = false;
            //throw new NotImplementedException();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {

        }

        private void panel6_Paint(object sender, PaintEventArgs e)
        {

        }

        private void panel7_Paint(object sender, PaintEventArgs e)
        {
            
        }

        private void textBox31_TextChanged(object sender, EventArgs e)
        {
          try
            {
                if (textBox31.Text.Length > 0 && textBox30.Text.Length > 0)
                {
                    textBox32.Text = (float.Parse(textBox31.Text) - float.Parse(textBox30.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            string connectString = $@"Data Source=192.168.0.89;Initial Catalog=Runtime;User ID=sa;Password=abc123!@#";
            string cmdsql = $@"SELECT v_Live.TagName , vValue 
                            FROM v_Live                           
                            LEFT JOIN AnalogTag ON AnalogTag.TagName =v_Live.TagName
                            LEFT JOIN EngineeringUnit ON AnalogTag.EUKey = EngineeringUnit.EUKey
                            LEFT JOIN QualityMap ON QualityMap.QualityDetail = v_Live.QualityDetail
                            WHERE v_Live.TagName IN ('展览馆.压力',
                            '正府街.压力',
                            '调度.需水状态',
                            '调度.调度模式',
                            '水量预测.时间点用水',
                            '水六厂A.二期出厂水秒流量',
                            '水六厂A.三期出厂水瞬时流量',
                            '水六厂A.一期出厂水瞬时流量',
                            '水六厂B.2#出水累计流量H',
                            '水六厂B.1#出水累计流量H',
                            '水六厂C.出水瞬时流量',                    
                            'SAC_水六厂A.S产水水量设定',
                            'SAC_水六厂B.S产水水量设定',
                            'SAC_水六厂C.S产水水量设定',
                            '水六厂A.三期出厂水水位',
                            'SAC_水七厂.S产水水量设定',
                            'SAC_水七厂二期.S产水水量设定',
                            'SAC_水七厂.Su总供水瞬时流量',
                            'SAC_水七厂.S清水池液位',
                            'SAC_水二厂.S总出水瞬时流量',
                            'SAC_水二厂.S产水水量设定',
'水二厂.1#出水','水二厂.2#出水','水二厂.3#出水','水二厂.4#出水','水二厂.5#出水','水二厂.6#出水','水二厂.7#出水','水二厂.8#出水','水二厂.9#出水','水二厂.10#出水',
'SAC_水五厂.S出水瞬时流量','SAC_水五厂.S产水水量设定',
'水五厂.1#出水','水五厂.2#出水','水五厂.3#出水','水五厂.4#出水','水五厂.5#出水','水五厂.6#出水','水五厂.7#出水','水五厂.8#出水','水五厂.9#出水','水五厂.10#出水','水五厂.11#出水',
'塔子山加压站.1#泵状态','塔子山加压站.2#泵状态', '塔子山加压站.3#泵状态', '塔子山加压站.4#泵状态',       
'SAC_塔子山.S清水池每米容积','塔子山加压站.进水瞬时流量','塔子山加压站.出水瞬时流量','塔子山加压站.2#清水池水位',
'凤凰.低区1#泵状态','凤凰.低区2#泵状态','凤凰.低区3#泵状态','凤凰.低区4#泵状态','凤凰.低区5#泵状态','凤凰.低区6#泵状态','凤凰.低区7#泵状态','凤凰.低区8#泵状态','凤凰.低区9#泵状态','凤凰.低区10#泵状态',
'凤凰.低区出水瞬时流量','凤凰.进水瞬时流量','SAC_凤凰.S清水池液位','SAC_凤凰.S清水池每米容积',
'SAC_洪河.S清水池每米容积','洪河.进水瞬时流量','洪河.S出水瞬时流量','SAC_洪河.S清水池液位',
'洪河.低区泵1状态','洪河.低区泵2状态','洪河.低区泵3状态','洪河.低区泵4状态',
'方桥一期.A阀开启度','方桥一期.B阀开启度','方桥一期.前后压力差','方桥一期.阀后压力','方桥一期.阀前压力',
'方桥二期.A阀开启度','方桥二期.B阀开启度','方桥二期.前后压力差','方桥二期.阀后压力','方桥二期.阀前压力',
'光华.A阀开启度','光华.B阀开启度','光华.前后压力差','光华.阀后压力','光华.阀前压力',
'南北大道.A阀开启度','南北大道.B阀开启度','南北大道.前后压力差','南北大道.阀后压力','南北大道.阀前压力',
'郎家.1#调流阀开启度','郎家.2#调流阀开启度','郎家.前后压差','郎家.阀后压力','郎家.阀前压力',
'青杠.1#阀开启度','青杠.2#阀开启度','青杠.前后压差','青杠.阀后压力','青杠.阀前压力',
'清波.1#阀开启度','清波.2#阀开启度','清波.前后压差','清波.阀后压力','清波.阀前压力',
'土门.1#阀开启度','土门.2#阀开启度','土门.前后压差','土门.阀后压力','土门.阀前压力',
'土桥.1#阀开启度','土桥.2#阀开启度','土桥.前后压差','土桥.阀后压力','土桥.阀前压力'

)";
            try
            {

                SqlConnection sqlCnt = new SqlConnection(connectString);
                sqlCnt.Open();
                SqlCommand command = new SqlCommand(cmdsql, sqlCnt);
                var datas = command.ExecuteReader();
                if (datas.HasRows)
                {
                    
                    float six1 = 0f, six2 = 0, six3 = 0, six4_1 = 0, six4_2 = 0, six5 = 0;
                    float abilitya = 0, abilityb = 0, abilityc = 0;
                    float abilty71 = 0, abilty72 = 0;
                    while (datas.Read())
                    {
                        try
                        {

                            if (datas["TagName"].ToString() == "展览馆.压力")
                            {
                                textBox76.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 3)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "正府街.压力")
                            {
                                textBox75.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 3)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "调度.需水状态")
                            {
                                textBox74.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "调度.调度模式")
                            {
                                textBox73.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "水量预测.时间点用水")
                            {
                                textBox77.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "水六厂A.二期出厂水秒流量")
                            {
                                six2 = float.Parse(datas["vValue"].ToString());
                            }
                            else if (datas["TagName"].ToString() == "水六厂A.三期出厂水瞬时流量")
                            {
                                six3 = float.Parse(datas["vValue"].ToString());
                            }
                            else if (datas["TagName"].ToString() == "水六厂A.一期出厂水瞬时流量")
                            {
                                six1 = float.Parse(datas["vValue"].ToString());
                            }
                            else if (datas["TagName"].ToString() == "水六厂B.2#出水累计流量H")
                            {
                                six4_2 = float.Parse(datas["vValue"].ToString());
                            }
                            else if (datas["TagName"].ToString() == "水六厂B.1#出水累计流量H")
                            {
                                six4_1 = float.Parse(datas["vValue"].ToString());
                            }
                            else if (datas["TagName"].ToString() == "水六厂C.出水瞬时流量")
                            {
                                six5 = float.Parse(datas["vValue"].ToString());
                            }
                            else if (datas["TagName"].ToString() == "SAC_水六厂A.S产水水量设定")
                            {
                                abilitya = float.Parse(datas["vValue"].ToString());
                            }
                            else if (datas["TagName"].ToString() == "SAC_水六厂B.S产水水量设定")
                            {
                                abilityb = float.Parse(datas["vValue"].ToString());
                            }
                            else if (datas["TagName"].ToString() == "SAC_水六厂C.S产水水量设定")
                            {
                                abilityc = float.Parse(datas["vValue"].ToString());
                            }
                            else if (datas["TagName"].ToString() == "水六厂A.三期出厂水水位")
                            {
                                textBox3.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "SAC_水七厂.S产水水量设定")
                            {
                                abilty71 = float.Parse(datas["vValue"].ToString());
                            }
                            else if (datas["TagName"].ToString() == "SAC_水七厂二期.S产水水量设定")
                            {
                                abilty72 = float.Parse(datas["vValue"].ToString());
                            }
                            else if (datas["TagName"].ToString() == "SAC_水七厂.Su总供水瞬时流量")
                            {
                                textBox6.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "SAC_水七厂.S清水池液位")
                            {
                                textBox4.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "SAC_水二厂.S总出水瞬时流量")
                            {
                                textBox22.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "SAC_水二厂.S产水水量设定")
                            {
                                textBox23.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "水二厂.1#出水")
                            {
                                checkBox28.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水二厂.2#出水")
                            {
                                checkBox27.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水二厂.3#出水")
                            {
                                checkBox26.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水二厂.4#出水")
                            {
                                checkBox25.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水二厂.5#出水")
                            {
                                checkBox24.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水二厂.6#出水")
                            {
                                checkBox23.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水二厂.7#出水")
                            {
                                checkBox22.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水二厂.8#出水")
                            {
                                checkBox21.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水二厂.9#出水")
                            {
                                checkBox20.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水二厂.10#出水")
                            {
                                checkBox19.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "SAC_水五厂.S出水瞬时流量")
                            {
                                textBox27.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "SAC_水五厂.S产水水量设定")
                            {
                                textBox26.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "水五厂.1#出水")
                            {
                                checkBox40.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水五厂.2#出水")
                            {
                                checkBox39.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水五厂.3#出水")
                            {
                                checkBox38.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水五厂.4#出水")
                            {
                                checkBox37.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水五厂.5#出水")
                            {
                                checkBox36.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水五厂.6#出水")
                            {
                                checkBox35.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水五厂.7#出水")
                            {
                                checkBox34.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水五厂.8#出水")
                            {
                                checkBox33.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水五厂.9#出水")
                            {
                                checkBox32.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水五厂.10#出水")
                            {
                                checkBox31.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "水五厂.11#出水")
                            {
                                checkBox30.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "塔子山加压站.1#泵状态")
                            {
                                checkBox1.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "塔子山加压站.2#泵状态")
                            {
                                checkBox2.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "塔子山加压站.3#泵状态")
                            {
                                checkBox3.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "塔子山加压站.4#泵状态")
                            {
                                checkBox4.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "SAC_塔子山.S清水池每米容积")
                            {
                                textBox9.Text = datas["vValue"].ToString();
                            }
                            else if (datas["TagName"].ToString() == "塔子山加压站.进水瞬时流量")
                            {
                                textBox10.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "塔子山加压站.出水瞬时流量")
                            {
                                textBox7.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "塔子山加压站.2#清水池水位")
                            {
                                textBox8.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "凤凰.低区1#泵状态")
                            {
                                checkBox9.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "凤凰.低区2#泵状态")
                            {
                                checkBox10.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "凤凰.低区3#泵状态")
                            {
                                checkBox11.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "凤凰.低区4#泵状态")
                            {
                                checkBox12.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "凤凰.低区5#泵状态")
                            {
                                checkBox13.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "凤凰.低区6#泵状态")
                            {
                                checkBox14.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "凤凰.低区7#泵状态")
                            {
                                checkBox15.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "凤凰.低区8#泵状态")
                            {
                                checkBox16.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "凤凰.低区9#泵状态")
                            {
                                checkBox17.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "凤凰.低区10#泵状态")
                            {
                                checkBox18.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "凤凰.低区出水瞬时流量")
                            {
                                textBox21.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "凤凰.进水瞬时流量")
                            {
                                textBox18.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "SAC_凤凰.S清水池液位")
                            {
                                textBox20.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "SAC_凤凰.S清水池每米容积")
                            {
                                textBox19.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "SAC_洪河.S清水池每米容积")
                            {
                                textBox14.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "洪河.进水瞬时流量")
                            {
                                textBox13.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "洪河.S出水瞬时流量")
                            {
                                textBox16.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "SAC_洪河.S清水池液位")
                            {
                                textBox15.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "洪河.低区泵1状态")
                            {
                                checkBox8.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "洪河.低区泵2状态")
                            {
                                checkBox7.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "洪河.低区泵3状态")
                            {
                                checkBox6.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "洪河.低区泵4状态")
                            {
                                checkBox5.Checked = int.Parse(datas["vValue"].ToString()) == 1 ? true : false;
                            }
                            else if (datas["TagName"].ToString() == "方桥一期.A阀开启度")
                            {
                                textBox45.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "方桥一期.B阀开启度")
                            {
                                textBox44.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "方桥一期.前后压力差")
                            {
                                textBox43.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "方桥一期.阀后压力")
                            {
                                textBox46.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "方桥一期.阀前压力")
                            {
                                textBox47.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "方桥二期.A阀开启度")
                            {
                                textBox50.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "方桥二期.B阀开启度")
                            {
                                textBox49.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "方桥二期.前后压力差")
                            {
                                textBox48.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "方桥二期.阀后压力")
                            {
                                textBox51.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "方桥二期.阀前压力")
                            {
                                textBox52.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "光华.A阀开启度")
                            {
                                textBox60.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "光华.B阀开启度")
                            {
                                textBox59.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "光华.前后压力差")
                            {
                                textBox58.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "光华.阀后压力")
                            {
                                textBox61.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "光华.阀前压力")
                            {
                                textBox62.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "郎家.1#调流阀开启度")
                            {
                                textBox35.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "郎家.2#调流阀开启度")
                            {
                                textBox34.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "郎家.前后压差")
                            {
                                textBox33.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "郎家.阀后压力")
                            {
                                textBox36.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "郎家.阀前压力")
                            {
                                textBox37.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "青杠.1#阀开启度")
                            {
                                textBox70.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "青杠.2#阀开启度")
                            {
                                textBox69.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "青杠.前后压差")
                            {
                                textBox68.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "青杠.阀后压力")
                            {
                                textBox71.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "青杠.阀前压力")
                            {
                                textBox72.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "清波.1#阀开启度")
                            {
                                textBox55.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "清波.2#阀开启度")
                            {
                                textBox54.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "清波.前后压差")
                            {
                                textBox53.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "清波.阀后压力")
                            {
                                textBox56.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "清波.阀前压力")
                            {
                                textBox57.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "土门.1#阀开启度")
                            {
                                textBox29.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "土门.2#阀开启度")
                            {
                                textBox28.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "土门.前后压差")
                            {
                                textBox27.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "土门.阀后压力")
                            {
                                textBox30.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "土门.阀前压力")
                            {
                                textBox31.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "土桥.1#阀开启度")
                            {
                                textBox65.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "土桥.2#阀开启度")
                            {
                                textBox64.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "土桥.前后压差")
                            {
                                textBox63.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "土桥.阀后压力")
                            {
                                textBox66.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "土桥.阀前压力")
                            {
                                textBox67.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "南北大道.A阀开启度")
                            {
                                textBox40.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "南北大道.B阀开启度")
                            {
                                textBox39.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "南北大道.前后压力差")
                            {
                                textBox38.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "南北大道.阀后压力")
                            {
                                textBox41.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                            else if (datas["TagName"].ToString() == "南北大道.阀前压力")
                            {
                                textBox42.Text = (Math.Round(float.Parse(datas["vValue"].ToString()), 2)).ToString();
                            }
                        }
                        catch
                        {
                            continue;
                        }
                    }
                    textBox2.Text = Math.Round(abilitya + abilityb + abilityc,2).ToString();
                    textBox1.Text = Math.Round(six1 + six2 + six3 + six4_1 + six4_2 + six5,2).ToString();
                    textBox5.Text = Math.Round(abilty71 + abilty72,2).ToString();
                    sqlCnt.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("读取失败，原因是"+ex.Message);
                
            }
        }

        private void textBox30_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox31.Text.Length > 0 && textBox30.Text.Length > 0)
                {
                    textBox32.Text = (float.Parse(textBox31.Text) - float.Parse(textBox30.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox67_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox67.Text.Length > 0 && textBox66.Text.Length > 0)
                {
                    textBox63.Text = (float.Parse(textBox67.Text) - float.Parse(textBox66.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox72_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox72.Text.Length > 0 && textBox71.Text.Length > 0)
                {
                    textBox68.Text = (float.Parse(textBox72.Text) - float.Parse(textBox71.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox66_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox67.Text.Length > 0 && textBox66.Text.Length > 0)
                {
                    textBox63.Text = (float.Parse(textBox67.Text) - float.Parse(textBox66.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox71_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox72.Text.Length > 0 && textBox71.Text.Length > 0)
                {
                    textBox68.Text = (float.Parse(textBox72.Text) - float.Parse(textBox71.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox36_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox37.Text.Length > 0 && textBox36.Text.Length > 0)
                {
                    textBox33.Text = (float.Parse(textBox37.Text) - float.Parse(textBox36.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox37_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox37.Text.Length > 0 && textBox36.Text.Length > 0)
                {
                    textBox33.Text = (float.Parse(textBox37.Text) - float.Parse(textBox36.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox62_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox62.Text.Length > 0 && textBox61.Text.Length > 0)
                {
                    textBox58.Text = (float.Parse(textBox62.Text) - float.Parse(textBox61.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox61_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox62.Text.Length > 0 && textBox61.Text.Length > 0)
                {
                    textBox58.Text = (float.Parse(textBox62.Text) - float.Parse(textBox61.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox57_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox57.Text.Length > 0 && textBox56.Text.Length > 0)
                {
                    textBox53.Text = (float.Parse(textBox57.Text) - float.Parse(textBox56.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox56_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox57.Text.Length > 0 && textBox56.Text.Length > 0)
                {
                    textBox53.Text = (float.Parse(textBox57.Text) - float.Parse(textBox56.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox42_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox42.Text.Length > 0 && textBox41.Text.Length > 0)
                {
                    textBox38.Text = (float.Parse(textBox42.Text) - float.Parse(textBox41.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox41_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox42.Text.Length > 0 && textBox41.Text.Length > 0)
                {
                    textBox38.Text = (float.Parse(textBox42.Text) - float.Parse(textBox41.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox47_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox47.Text.Length > 0 && textBox46.Text.Length > 0)
                {
                    textBox43.Text = (float.Parse(textBox47.Text) - float.Parse(textBox46.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox46_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox47.Text.Length > 0 && textBox46.Text.Length > 0)
                {
                    textBox43.Text = (float.Parse(textBox47.Text) - float.Parse(textBox46.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox52_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox52.Text.Length > 0 && textBox51.Text.Length > 0)
                {
                    textBox48.Text = (float.Parse(textBox52.Text) - float.Parse(textBox51.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox51_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (textBox52.Text.Length > 0 && textBox51.Text.Length > 0)
                {
                    textBox48.Text = (float.Parse(textBox52.Text) - float.Parse(textBox51.Text)).ToString();
                }
            }
            catch
            {

            }
        }

        private void textBox11_TextChanged(object sender, EventArgs e)
        {
            textBox11.BackColor = Color.White;
            try
            {
                int.Parse(textBox11.Text.Trim());
            }
            catch
            {
                textBox11.BackColor = Color.Red;
            }
         
        }

        private void textBox12_TextChanged(object sender, EventArgs e)
        {
            textBox12.BackColor = Color.White;
            try
            {
                int.Parse(textBox12.Text.Trim());
            }
            catch
            {
                textBox12.BackColor = Color.Red;
            }
        }

        private void textBox17_TextChanged(object sender, EventArgs e)
        {
            textBox17.BackColor = Color.White;
            try
            {
                int.Parse(textBox17.Text.Trim());
            }
            catch
            {
                textBox17.BackColor = Color.Red;
            }
        }
    }
}
